package com.ruoyi.develop.orderCommissionRule.service.impl;

import java.util.List;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.DateUtils;
        import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.ruoyi.develop.orderCommissionRule.mapper.OrderCommissionRuleMapper;
import com.ruoyi.develop.orderCommissionRule.domain.OrderCommissionRule;
import com.ruoyi.develop.orderCommissionRule.service.IOrderCommissionRuleService;

/**
 * 订单提成规则Service业务层处理
 * @author lmm
 * @date 2024-11-14
 */
@Service
public class OrderCommissionRuleServiceImpl implements IOrderCommissionRuleService {
    @Resource
    private OrderCommissionRuleMapper orderCommissionRuleMapper;

    /**
     * 查询订单提成规则
     * @param id 订单提成规则主键
     * @return 订单提成规则
     */
    @Override
    public OrderCommissionRule selectById(String id) {
        return orderCommissionRuleMapper.selectById(id);
    }

    /**
     * 查询订单提成规则列表
     * @param entity 订单提成规则
     * @return 订单提成规则
     */
    @Override
    public List<OrderCommissionRule> selectList(OrderCommissionRule entity) {
        return orderCommissionRuleMapper.selectList(entity);
    }

    /**
     * 新增订单提成规则
     * @param entity 订单提成规则
     * @return 结果
     */
    @Override
    public int insert(OrderCommissionRule entity) {
        if(StringUtils.isBlank(entity.getId())){
            entity.setId(IdUtils.fastSimpleUUID());
        }
                entity.setCreateBy(SecurityUtils.getUsername());
                entity.setCreateTime(DateUtils.getNowDate());
            return orderCommissionRuleMapper.insert(entity);
    }

    /**
     * 修改订单提成规则
     * @param entity 订单提成规则
     * @return 结果
     */
    @Override
    public int update(OrderCommissionRule entity) {
                entity.setUpdateBy(SecurityUtils.getUsername());
                entity.setUpdateTime(DateUtils.getNowDate());
        return orderCommissionRuleMapper.update(entity);
    }

    /**
     * 批量删除订单提成规则
     * @param ids 需要删除的订单提成规则主键
     * @return 结果
     */
    @Override
    public int deleteByIds(String[] ids) {
        return orderCommissionRuleMapper.deleteByIds(ids);
    }

    /**
     * 删除订单提成规则信息
     * @param id 订单提成规则主键
     * @return 结果
     */
    @Override
    public int deleteById(String id) {
        return orderCommissionRuleMapper.deleteById(id);
    }

    @Override
    public OrderCommissionRule getByAreaAndReturnDays(String area, String returnDays) {
        return orderCommissionRuleMapper.getByAreaAndReturnDays(area, returnDays);
    }


}
